/*
 * @Author: czy
 * @Date: 2021-07-11 22:14:33
 * @LastEditTime: 2021-07-12 21:39:29
 */
#include "stdarg.h"
#include "string.h"
#include "vsprintf.h"

#include "sys/config.h"

#include "../lib/output.h"

static char BUFFER[BUF_SIZE];

/**
 * @description: Formats a string in the specified format, and output to standard output device.
 * @param format    Format string.
 * @param args      Parameter list.
 * @return The length of the string in the buffer.
 */
int vprintk(const char *format, va_list args)
{
    int n;
    strzero(BUFFER, BUF_SIZE);
    n = vsprintf(BUFFER, format, args);
    vga_put_chars(BUFFER);
    uart_put_chars(BUFFER);
    return n;
}

/**
 * @description: Formats a string in the specified format, and output to standard output device.
 * @param format    Format string.
 * @return The length of the string in the buffer.
 */
int printk(const char *format, ...)
{
    int n;
    va_list args;
    va_start(args, format);
    n = vprintk(format, args);
    va_end(args);
    return n;
}